import { SphereGeometry, ImageUtils, Texture, MeshBasicMaterial, Mesh } from "three";
import SimObject from "../../../../src/util/sim/SimObject";


export default class Earth extends SimObject {

    public static ROTATION_Y: number = 0.0025;
    public static TILT: number = 0.41;

    public earthmap: string;
    public geometry: SphereGeometry;
    public texture: Texture;
    public material: MeshBasicMaterial;
    public mesh: Mesh;

    public constructor() {
        super();
        this.earthmap = '../../images/earth_surface_2048.jpg';
        this.geometry = new SphereGeometry(1, 32, 32);
        this.texture = ImageUtils.loadTexture(this.earthmap);
        this.material = new MeshBasicMaterial({ map: this.texture });
        this.mesh = new Mesh(this.geometry, this.material);

        this.mesh.rotation.x = Earth.TILT;
        this.setObject3D(this.mesh);
    }

    public update(): void {
        this.object3D.rotation.y += Earth.ROTATION_Y;
    }
}